package cn.net.shuxing.yifu.common.service;


import cn.net.shuxing.yifu.common.bean.UserInfo;
import cn.net.shuxing.yifu.common.constant.OssConstant;
import cn.net.shuxing.yifu.common.mapper.UserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoService extends BaseService<UserInfo, UserInfoMapper>{

    @Autowired
    private OssCommonService ossCommonService;

    @Override
    protected void complete(UserInfo bean) {
        if (bean == null)
            return;
        String picture = bean.getPicture();
        String defaultPictureUrl = ossCommonService.getUrl(OssConstant.ossBucketName, picture);
        bean.setPictureOssUrl(defaultPictureUrl);
    }

    public boolean uploadPicture(Integer userId, byte[] picture,String suffix)
    {
        return ossCommonService.uploadFile(OssConstant.ossBucketName,"userId" + userId + "picture.png", picture,suffix);
    }

}
